import java.util.ArrayList;
import java.util.List;

public class PythagoreanTriplets {

    // 判断两个数是否互质
    private static boolean isCoprime(int a, int b) {
        while (b != 0) {
            int temp = b;
            b = a % b;
            a = temp;
        }
        return a == 1;
    }

    // 判断三个数是否两两互质
    private static boolean areCoprime(int a, int b, int c) {
        return isCoprime(a, b) && isCoprime(a, c) && isCoprime(b, c);
    }

    // 找出给定范围 [N, M] 内的所有勾股数元祖
    public static List<int[]> findPythagoreanTriplets(int N, int M) {
        List<int[]> triplets = new ArrayList<>();
        for (int a = N; a <= M; a++) {
            for (int b = a + 1; b <= M; b++) {
                for (int c = b + 1; c <= M; c++) {
                    if (a * a + b * b == c * c && areCoprime(a, b, c)) {
                        triplets.add(new int[]{a, b, c});
                    }
                }
            }
        }
        return triplets;
    }

    public static void main(String[] args) {
        int N = 1;
        int M = 20; // 示例范围，可根据需要修改
        List<int[]> result = findPythagoreanTriplets(N, M);
        for (int[] triplet : result) {
            System.out.println("(" + triplet[0] + ", " + triplet[1] + ", " + triplet[2] + ")");
        }
    }
}